<template>
  <el-date-picker
    v-model="begModelTime"
    :type="type"
    :name="name"
    :readonly="readonly"
    placeholder="开始日期"
    :format="format"
    :value-format="format"
    @change="handleDatePickerChange"
  />
</template>
<script>
export default {
  name: 'DatePickerModule',
  emits: ['input', 'change'],
  props: {
    readonly: {
      type: Boolean,
      default: false
    },
    type: {
      type: String,
      default: 'datetime'
    },
    name: {
      type: String,
      default: ''
    },
    format: {
      type: String,
      default: 'YYYY-MM-DD HH:mm:ss'
    },
    value: {
      type: [Date, Array, String],
      default: ''
    }
  },
  data() {
    return {
      begModelTime: this.value
    }
  },
  watch: {
    value () {
      this.begModelTime = this.value
    }
  },
  methods: {
    handleDatePickerChange(val) {
      console.log(val)
      this.$emit('input', val)
      this.$emit('change', val)
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
